import yaml
from yaml import FullLoader
from common.tools import get_project_path, build_path


class GetConf:
    def __init__(self):
        with open(get_project_path() + build_path("config", "environment.yaml", add_sep_before=True), "r",
                  encoding="utf-8") as file:
            self.env = yaml.load(file, Loader=FullLoader)

    def get_plat_info(self):
        return self.env

    def get_device_caps(self, device):
        """加载设备配置"""
        with open(get_project_path() + build_path("config", "environment.yaml", add_sep_before=True), "r",
                  encoding="utf-8") as file:
            devices = yaml.safe_load(file)["devices"]
        for dev in devices:
            if dev["udid"] == device:
                return dev
        return None


if __name__ == '__main__':
    print(GetConf().get_device_caps("emulator-5554"))
